package
{
	import flash.display.BitmapData;
	import flash.display.Graphics;
	import flash.display.MovieClip;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;
	
	public class MapObjectMovie extends MapObject
	{
		public var mvData:MovieClip;
		protected var bmTemp:BitmapData;
		protected var width:Number;
		protected var height:Number;
		public function MapObjectMovie(id:uint, path:String)
		{
			super(id, path);
		}
		public override function GetType():uint
		{
			return MapObject.MovieObject;
		}
		public override function SetDisplayData(o:Object):void
		{
			mvData = MovieClip(o);
			width = mvData.Bound.width;
			height = mvData.Bound.height;
			bmTemp = new BitmapData(width,height,true);
		}
		public override function GetDisplayData():Object
		{
			return mvData;	
		}
		public override function Draw(g:Graphics, x:int,y:int):void
		{
			bmTemp.fillRect(new Rectangle(0,0,width,height),0x00000000);
			bmTemp.draw(mvData);
			var matrix:Matrix = new Matrix();
			matrix.translate(x, y);
			g.beginBitmapFill(bmTemp,matrix);
			g.drawRect(x,y,width,height);
			g.endFill();
		}
		public override function DrawHighlight(g:Graphics, x:int,y:int):void
		{
			/*
			var matrix:Matrix = new Matrix();
			matrix.translate(x, y);
			var bmHL:BitmapData = bmData.clone();
			var cTransform:ColorTransform = new ColorTransform();
			cTransform.color = 200;
			bmHL.colorTransform(new Rectangle(0,0,bmHL.width,bmHL.height),cTransform);
			g.beginBitmapFill(bmHL,matrix);
			g.drawRect(x,y,bmHL.width,bmHL.height);
			g.endFill();
			*/
			var cTransform:ColorTransform = new ColorTransform();
			cTransform.color = 200;
			bmTemp.fillRect(new Rectangle(0,0,width,height),0x00000000);
			bmTemp.draw(mvData,null,cTransform);
			var matrix:Matrix = new Matrix();
			matrix.translate(x, y);
			g.beginBitmapFill(bmTemp,matrix);
			g.drawRect(x,y,width,height);
			g.endFill();
		}
		public override function GetWidth():uint
		{
			return width;
		}
		public override function GetHeight():uint
		{
			return height;	
		}
	}
}